package lisen.stes.util;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

import lisen.stes.entity.User;

public class NameStore {
	
	public static final List<User> users = new ArrayList<User>();
	
	static {
		for (int i = 0; i < 200; i++) {
			User user = new User();
			user.setId(i);
			user.setPassword(String.valueOf(random()));
			user.setUsername(RandomName.ranName(1));
			users.add(user);
		}
	}
	
	private static final int random() {
		return ThreadLocalRandom.current().nextInt(1000, 10000);
	}
	
	public static List<User> query(String keyword) {
		List<User> result = new ArrayList<User>();
		for (User user : users) {
			if (user.getUsername().indexOf(keyword) >= 0) {
				result.add(user);
			}
		}
		return result;
	}
}
